package com.jianzh5.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * TResource entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_resource", catalog = "")
public class TResource implements java.io.Serializable {

	// Fields

	private Integer id;
	private TResource TResource;
	private String name;
	private String remark;
	private String url;
	private Integer seq;
	private Integer level;
	private String icon;
	private String permission;
	private Set<TResource> TResources = new HashSet<TResource>(0);
	private Set<TRole> TRoles = new HashSet<TRole>(0);

	// Constructors

	/** default constructor */
	public TResource() {
	}

	/** full constructor */
	public TResource(TResource TResource, String name, String remark,
			String url, Integer seq, Integer level, String icon,
			Set<TResource> TResources, Set<TRole> TRoles) {
		this.TResource = TResource;
		this.name = name;
		this.remark = remark;
		this.url = url;
		this.seq = seq;
		this.level = level;
		this.icon = icon;
		this.TResources = TResources;
		this.TRoles = TRoles;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	public TResource getTResource() {
		return this.TResource;
	}

	public void setTResource(TResource TResource) {
		this.TResource = TResource;
	}

	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "remark", length = 100)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "url", length = 100)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "seq")
	public Integer getSeq() {
		return this.seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

	@Column(name = "level")
	public Integer getLevel() {
		return this.level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Column(name = "icon", length = 50)
	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}
	
	@Column(name = "permission", length = 100)
	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TResource")
	public Set<TResource> getTResources() {
		return this.TResources;
	}

	public void setTResources(Set<TResource> TResources) {
		this.TResources = TResources;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TResources")
	public Set<TRole> getTRoles() {
		return this.TRoles;
	}

	public void setTRoles(Set<TRole> TRoles) {
		this.TRoles = TRoles;
	}

}